package com.tourism.home.controller.user;

import com.tourism.home.entity.Result;
import com.tourism.home.service.CollectionService;
import com.tourism.home.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class CollectionController {
    @Autowired
    CollectionService collectionService;

    //ok
    @GetMapping("/collection/users/{uid}")
    Result getUserCollectionUserByUID(@PathVariable("uid") Integer uid){
        return ResultUtil.success(collectionService.getUserCollectionUserByUID(uid));
    }

    //ok
    @GetMapping("/collection/forums/{uid}")
    Result getUserCollectionForumByUID(@PathVariable("uid") Integer uid){
        return ResultUtil.success(collectionService.getUserCollectionForumByUID(uid));
    }

    //ok
    @GetMapping("/collection/posts/{uid}")
    Result getUserCollectionPostByUID(@PathVariable("uid") Integer uid){
        System.out.println(uid);
        return ResultUtil.success(collectionService.getUserCollectionPostByUID(uid));
    }



    @GetMapping("/user/collections/cnums/{uid}")
    Result getUserCollectionNumsByUID(@PathVariable("uid") Integer uid){
        return ResultUtil.success(collectionService.getUserCollectionNumsByUID(uid));
    }

    //ok
    @DeleteMapping("/collection/del/{id}")
    Result deleteUserCollectionByUIDAndOID(@PathVariable("id") Integer id){
        return ResultUtil.success(collectionService.deleteUserCollectionByUIDAndOID(id));
    }


    //ok
    @GetMapping("/user/followers/{oid}")
    Result getUserFollowersByUID(@PathVariable("oid") Integer oid){
        return ResultUtil.success(collectionService.getUserFollowersByUID(oid));
    }

    //ok
    @GetMapping("/collection/post/uids/{opid}")
    Result getCollectionPostUids(@PathVariable("opid") Integer opid){
        return ResultUtil.success(collectionService.getCollectionPostUids(opid));
    }

    //ok
    @GetMapping("/collection/user/uids/{ouid}")
    Result getCollectionUserUids(@PathVariable("ouid") Integer ouid){
        return ResultUtil.success(collectionService.getCollectionUserUids(ouid));
    }

    //ok
    @GetMapping("/collection/forum/uids/{ofid}")
    Result getCollectionForumUids(@PathVariable("ofid") Integer ofid){
        return ResultUtil.success(collectionService.getCollectionForumUids(ofid));
    }


    //ok
    @PutMapping("/collection/user")
    Result addCollectionU(@RequestParam("uid") Integer uid, @RequestParam("ouid") Integer ouid){
        return ResultUtil.success(collectionService.addCollectionU(uid,ouid));
    }

    //ok
    @PutMapping("/collection/forum")
    Result addCollectionF(@RequestParam("uid") Integer uid, @RequestParam("ofid") Integer ofid){
        return ResultUtil.success(collectionService.addCollectionF(uid,ofid));
    }

    //ok
    @PutMapping("/collection/post")
    Result addCollectionP(@RequestParam("uid") Integer uid, @RequestParam("opid") Integer opid){
        return ResultUtil.success(collectionService.addCollectionP(uid,opid));
    }

    //ok
    @DeleteMapping("/collection/user/delete")
    Result deleteCollectionU(@RequestParam("uid") Integer uid, @RequestParam("ouid") Integer ouid){
        return ResultUtil.success(collectionService.deleteCollectionU(uid,ouid));
    }

    //ok
    @DeleteMapping("/collection/forum/delete")
    Result deleteCollectionF(@RequestParam("uid") Integer uid, @RequestParam("ofid") Integer ofid){
        return ResultUtil.success(collectionService.deleteCollectionF(uid,ofid));
    }

    //ok
    @DeleteMapping("/collection/post/delete")
    Result deleteCollectionP(@RequestParam("uid") Integer uid, @RequestParam("opid") Integer opid){
        return ResultUtil.success(collectionService.deleteCollectionP(uid,opid));
    }

}
